#include "wxsprintdialog.h"
#include "../wxsitemresdata.h"
#include <wx/printdlg.h>

namespace {
  wxsRegisterItem<wxsPrintDialog> Reg( _T( "PrintDialog" ), _T( "动画控制" ), wxsTTool, _T( "对话框" ), 110, false );
}

wxsPrintDialog::wxsPrintDialog( wxsItemResData* Data ):
  wxsTool( Data, &Reg.Info ),
  m_bEnableHelp( false ),
  m_bEnablePageNumbers( true ),
  m_bEnablePrintToFile( true ),
  m_bEnableSelection( false ),
  m_bCollate( false ),
  m_bPrintToFile( false ),
  m_bSelection( false ),
  m_iFromPage( 0 ),
  m_iToPage( 0 ),
  m_iMinPage( 0 ),
  m_iMaxPage( 0 ),
  m_iNoCopies( 1 ) {
}


void wxsPrintDialog::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/printdlg.h>" ), GetInfo().ClassName, hfInPCH );
      wxString sDataName = GetCoderContext()->GetUniqueName( _T( "printDialogData" ) );
      AddDeclaration( wxString::Format( wxT( "wxPrintDialogData  *%s;" ), sDataName.wx_str() ) );
      Codef( _T( "\t%s = new wxPrintDialogData;\n" ), sDataName.wx_str() );
      if( m_bEnableHelp ) {
        Codef( _T( "\t%s->EnableHelp(%b);\n" ), sDataName.wx_str(), m_bEnableHelp );
      }
      if( !m_bEnablePageNumbers ) {
        Codef( _T( "\t%s->EnablePageNumbers(%b);\n" ), sDataName.wx_str(), m_bEnablePageNumbers );
      }
      if( !m_bEnablePrintToFile ) {
        Codef( _T( "\t%s->EnablePrintToFile(%b);\n" ), sDataName.wx_str(), m_bEnablePrintToFile );
      }
      if( m_bEnableSelection ) {
        Codef( _T( "\t%s->EnableSelection(%b);\n" ), sDataName.wx_str(), m_bEnableSelection );
        if( m_bSelection ) {
          Codef( _T( "\t%s->SetSelection(%b);\n" ), sDataName.wx_str(), m_bSelection );
        }
      }
      if( m_bCollate ) {
        Codef( _T( "\t%s->SetCollate(%b);\n" ), sDataName.wx_str(), m_bCollate );
      }
      if( m_iFromPage > 0 ) {
        Codef( _T( "\t%s->SetFromPage(%d);\n" ), sDataName.wx_str(), m_iFromPage );
      }
      if( m_iToPage > 0 ) {
        Codef( _T( "\t%s->SetToPage(%d);\n" ), sDataName.wx_str(), m_iToPage );
      }
      if( m_iMinPage > 0 ) {
        Codef( _T( "\t%s->SetMinPage(%d);\n" ), sDataName.wx_str(), m_iMinPage );
      }
      if( m_iMaxPage > 0 ) {
        Codef( _T( "\t%s->SetMaxPage(%d);\n" ), sDataName.wx_str(), m_iMaxPage );
      }
      if( m_iNoCopies > 1 ) {
        Codef( _T( "\t%s->SetNoCopies(%d);\n" ), sDataName.wx_str(), m_iNoCopies );
      }
      Codef( _T( "%C(%W, %v);\n" ), sDataName.wx_str() );
      BuildSetupWindowCode();
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsPrintDialog::OnBuildCreatingCode" ), GetLanguage() );
    }
  }
}


void wxsPrintDialog::OnEnumToolProperties( M_Code_unused long Flags ) {
  WXS_BOOL( wxsPrintDialog, m_bEnableHelp, _T( "Enable Help" ), _T( "enable_help" ), false )
  WXS_BOOL( wxsPrintDialog, m_bEnablePageNumbers, _T( "Enable Page Numbers" ), _T( "enable_page_numbers" ), true )
  WXS_LONG( wxsPrintDialog, m_iFromPage,  _T( "From Page" ), _T( "from_page" ), 0 )
  WXS_LONG( wxsPrintDialog, m_iToPage,  _T( "To Page" ), _T( "to_page" ), 0 )
  WXS_LONG( wxsPrintDialog, m_iMinPage,  _T( "Min. Page" ), _T( "min_page" ), 0 )
  WXS_LONG( wxsPrintDialog, m_iMaxPage,  _T( "Max. Page" ), _T( "max_page" ), 0 )
  WXS_LONG( wxsPrintDialog, m_iNoCopies,  _T( "Number of Copies" ), _T( "number_of_copies" ), 1 )
  WXS_BOOL( wxsPrintDialog, m_bCollate, _T( "Collate" ), _T( "collate" ), false )
  WXS_BOOL( wxsPrintDialog, m_bEnablePrintToFile, _T( "Enable Print To File" ), _T( "enable_print_to_file" ), true )
  WXS_BOOL( wxsPrintDialog, m_bPrintToFile, _T( "Print To File" ), _T( "print_to_file" ), false )
  WXS_BOOL( wxsPrintDialog, m_bEnableSelection, _T( "Enable Selection" ), _T( "enable_selection" ), false )
  WXS_BOOL( wxsPrintDialog, m_bSelection, _T( "Selection" ), _T( "selection" ), false )
}
